﻿using System;
using System.Numerics;

/*
	Write a program that reads a number N and calculates 
	the sum of the first N members of the sequence of Fibonacci:
 	0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, …
 	Each member of the Fibonacci sequence (except the
 	first two) is a sum of the previous two members.
 */

class FibonacciToN
{
    static void Main(string[] args)
    {
        Console.Write("Enter N: ");
        int n = Convert.ToInt32(Console.ReadLine());
        
        BigInteger prevFibonacciMember = 0;
        BigInteger currentFibonacciMember = 1;
        BigInteger sumFibonacci = 1;

        if (n != 1)
        {
            for (int i = 2; i <= n; i++)
            {
                currentFibonacciMember = currentFibonacciMember + prevFibonacciMember;
                prevFibonacciMember = currentFibonacciMember - prevFibonacciMember;
                sumFibonacci += currentFibonacciMember;
            }
        }

        Console.WriteLine("The sum of the first {0} members of the sequence of Fibonacci is:\n{1}", n, sumFibonacci);

    }
}

